Add /mcp update command to reload MCP servers without restart#1
Conversation
- MCP Client: add Reconnect() method that closes old connections, rebuilds servers from new config, re-initializes, and re-embeds tools - Agent: add ReloadMCP() to expose reconnect to the handler layer - Telegram: add /mcp command with "update"/"reload" subcommands that re-reads config/mcp.json and reconnects all MCP servers https://claude.ai/code/session_01VtMjyBkcnrX8AZDuPj67XT
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| } | ||
|
|
||
| return len(c.tools), nil | ||
| } |
There was a problem hiding this comment.
Concurrent map access causes fatal runtime panic
High Severity
Reconnect writes to c.servers, c.toolServers, and c.tools without any synchronization. The Telegram handler dispatches up to 10 updates concurrently in goroutines, so a /mcp update command can race with a user message that reads these same maps via CallTool or LLMToolsForQuery. In Go, concurrent read+write on a map is a fatal runtime panic — not just a data race.
Additional Locations (1)
| } | ||
| } | ||
| c.servers[name] = srv | ||
| } |
There was a problem hiding this comment.
Duplicated server-building logic in Reconnect and NewClient
Low Severity
The server construction loop in Reconnect (URL validation, server struct creation, allow/deny tool maps) is a near-exact copy of NewClient. Duplicating this logic means future changes (e.g., new server fields or validation rules) need to be applied in both places, risking inconsistent behavior.


∙ MCP Client (internal/mcp/client.go): add Reconnect() method — closes existing connections, rebuilds servers from new config, re-initializes, and re-embeds tools
∙ Agent (internal/agent/agent.go): add ReloadMCP() proxy method to expose reconnect to the handler layer
∙ Telegram (internal/telegram/handler.go): add /mcp update command (alias /mcp reload) — re-reads config/mcp.json and reconnects all MCP servers on the fly
Note
Medium Risk
Adds runtime MCP reconnection and config reload, which touches external service connectivity and tool discovery/embedding state; failures could temporarily drop tools or change tool availability mid-session.
Overview
Adds a runtime MCP reload path so MCP server configuration can be updated without restarting the bot.
The MCP client now supports
Reconnect()to close existing HTTP pools, rebuild server state from a newmcp.jsonconfig, re-run tool discovery, and re-embed tools when embeddings are enabled. This is exposed viaAgent.ReloadMCP(), and the Telegram bot adds a new/mcp update(alias/mcp reload) command that reloadsconfig/mcp.json, reconnects servers with a timeout, and reports the resulting tool count.Written by Cursor Bugbot for commit 791dab8. This will update automatically on new commits. Configure here.